package http

import (
	"github.com/beego/beego/v2/server/web"
	"github.com/beego/beego/v2/server/web/filter/cors"
)

func init() {
	web.InsertFilter("*", web.BeforeRouter, cors.Allow(&cors.Options{
		AllowAllOrigins: true,
		//AllowOrigins:     []string{"localhost","localhost:8081"},
		AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
		AllowHeaders: []string{"access-token", "a-auth-token", "x-auth-token", "Origin",
			"Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type",
			"Wechatpay-Timestamp",
			"Wechatpay-Nonce",
			"Wechatpay-Signature",
			"Wechatpay-Serial",
		},
		ExposeHeaders:    []string{"access-token", "Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
		AllowCredentials: true,
	}))
}
